import LocalStorage from "../../framework/utils/LocalStorage";

/**
 * 本地开关控制对象.
 */
class Settings {
    public musicOpen: boolean = true;
    public effectOpen: boolean = true;
    public lastTS: number = 0;
    public lastLogin: number = 0;

    constructor() {
        LocalStorage.getObj("user_profile_settings", this);
    }

    public save() {
        LocalStorage.setObj("user_profile_settings", this);
    }

    public updateLastLogin() {
        this.lastLogin = cc.sys.now();
        this.save();
    }

    public isNewUser(): boolean {
        return this.lastLogin <= 0;
    }
}

export const settings: Settings = new Settings();